package org.erepublik.company.controllers;

import org.erepublik.company.Hospital;
import org.erepublik.company.service.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/hospital.html")
public class HospitalController  extends AbstractController  {

    @Autowired
    private HospitalService hospitalService;
    
    @RequestMapping(method = RequestMethod.GET)
    public String showForm(ModelMap model) {
        fillModelMap(model);

        Hospital[] hospitals = hospitalService.getActiveHospitals();
        System.out.println(" liczba szpitali !!! " + hospitals.length);
        model.addAttribute("hospitals", hospitals);

        return "hospital";
    }
    
}
